package com.woniu.internalcommon.response;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class TerminalResponse {

    private String tid;

    private Long carId;

    private String longitude ;
    private String latitude ;

    /**
     * 映射转换映射构造函数
     * @param terminalInfoResponse
     */
    public  TerminalResponse(TerminalInfoResponse terminalInfoResponse) {
    	this.tid = terminalInfoResponse.getTid();
        // 判断描述是否为数字
        this.carId = terminalInfoResponse.getDesc().matches("^\\d+$")
                    ?Long.parseLong(terminalInfoResponse.getDesc()):null;
        this.longitude = terminalInfoResponse.getLocation().getLongitude();
        this.latitude = terminalInfoResponse.getLocation().getLatitude();
    }


}
